//合并两个有序链表
class Solution5 {
   public  static ListNode mergeTwoLists(ListNode head1,
                                               ListNode head2) {
        ListNode newH = new ListNode(-1);
        ListNode tmpH = newH;

        while (head1 != null && head2 != null) {
           if(head1.val < head2.val){
            tmpH.next = head1;
            head1 = head1.next;
           }else{
            tmpH.next = head2;
            head2 = head2.next;
           }
            tmpH = tmpH.next;
        }

        if (head1 != null) {
            tmpH.next = head1;
        }

        if (head2 != null) {
            tmpH.next = head2;
        }
        return newH.next;
    }
}